/**
 * @Description: 工具Service
 * @author 焦政
 * @date 2019/4/7
 */
const Service = require('egg').Service;
const svgCaptcha = require('svg-captcha'); // 图片验证码插件

class ToolsService extends Service {
  /**
   * 生成图片验证码
   * @returns 图片验证码
   */
  async appendSvg() {
    const captcha = svgCaptcha.create({
      size: 4,
      fontSize: 50,
      width: 100,
      height: 40,
      bacground: '#cc9966'
    });
    this.ctx.session.code = captcha.text;
    return captcha;
  }
}

module.exports = ToolsService

